//我tm考CSPS还得做物理题？？？
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const int N = 1e5+5;

int t; 
int n, m, L, V;
struct CAR{
    int d, v, a;
    int os;
}c[N];
int p[N];
int cnt;
int ans;
bool pf0 = true, pf1 = true, pf2 = true;
int opt;
bool csy[25];
double getSpeed(double v, double a, double s){
    return sqrt(v * v + 2.0 * a * s);
}
double getLength(double v, double a, double t){
    return v * t + 0.5 * a * t * t;
}
double getMaxLength(double v1, double v0, double a){
    //only for a < 0
    return (v1 * v1 - v0 * v0) / 2.0 / a;
}
signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    cin >> t;
    while(t--){
        cin >> n >> m >> L >> V;
        for(int i = 1; i <= n; i++){
            cin >> c[i].d >> c[i].v >> c[i].a;
            if(c[i].a != 0) pf0 = false;
            if(c[i].a < 0) pf1 = false;
            if(c[i].a >= 0) pf2 = false;
        }
        for(int i = 1; i <= m; i++)
            cin >> p[i];
        //---------------------------------------pf
        cnt = 0, ans = 0;
        if(pf0){ // A OK!
            for(int i = 1; i <= n; i++){
                if(c[i].d > p[m]) continue;
                if(c[i].v > V){
                    cnt++;
                }
            }
            if(cnt){
                cout << cnt << " " << m - 1 << endl;
            } else {
                cout << 0 << " " << m << endl;
            }
            opt++;
            continue;
        }
        else if(pf1){ // B OK!
            for(int i = 1; i <= n; i++){
                if(c[i].d > p[m]) continue;
                double v = getSpeed(c[i].v, c[i].a, p[m] - c[i].d);
                if(v > V){
                    cnt++;
                }
            }
            if(cnt){
                cout << cnt << " " << m - 1 << endl;
            } else {
                cout << 0 << " " << m << endl;
            }
            opt++;
            continue;
        }
        else if(pf2){ // C
        }
        //---------------------------------------default
        cnt = 0, ans = 0;
        for(int i = 1; i <= n; i++){
            // s = c[i].d
            if(c[i].a >= 0){
                if(c[i].d > p[m]) continue;
                for(int j = 1; j <= m; j++){
                    if(p[j] < c[i].d) continue;
                    double v = getSpeed(c[i].v, c[i].a, p[j] - c[i].d);
                    if(v > V){
                        if(!c[i].os){
                            cnt++; c[i].os = 1;
                        }
                        csy[j] = 1;
                    }
                }
            } else {
                double maxs = getMaxLength(0, c[i].v, c[i].a);
                if(maxs + c[i].d > L) continue;
                for(int j = 1; j <= m; j++){ //->
                    if(p[j] < c[i].d || p[j] > c[i].d + maxs) continue;
                    double v = getSpeed(c[i].v, c[i].a, p[j] - c[i].d);
                    //cout << "v=" << v << " ";
                    if(v > V){
                        if(!c[i].os){
                            cnt++; c[i].os = 1;
                        }
                        csy[j] = 1;
                    }
                }// <-
                for(int j = m; j >= 1; j--){
                    //start from maxs, v0 = 0;
                    if(p[m] >= maxs) continue;
                    double v = getSpeed(0, -1 * c[i].a, maxs - p[j]);
                    //cout << "v=" << v << " ";
                    if(v > V){
                        if(!c[i].os){
                            cnt++; c[i].os = 1;
                        }
                        csy[j] = 1;
                    }
                }
            }
        }
        for(int j = 1; j <= m; j++)
            if(csy[j]) ans++;
        cout << cnt << " " << m - ans << endl; 
    }
    return 0;
}